﻿
using AutoMapper;
using Enferno.Public.Web.Models;
using Enferno.StormApiClient.Shopping;

namespace Enferno.Public.Web.Builders
{
    public class BasketBuilder :
        BasketBaseBuilder<BasketModel, BasketItemModel, PromotionModel, OnHandStatusModel, PriceModel, ProductFileModel>
    {

    }

    public class BasketBaseBuilder<TBasketModel, TBasketItemModel, TPromotionModel, TOnHandStatusModel, TPriceModel, TProductFileModel> : BuilderBase
        where TBasketModel: BasketBaseModel<TBasketItemModel, TPromotionModel, TOnHandStatusModel, TPriceModel, TProductFileModel> 
        where TBasketItemModel: BasketItemBaseModel<TPriceModel>
        where TPromotionModel: PromotionBaseModel<TProductFileModel>
        where TOnHandStatusModel: OnHandStatusModel
        where TPriceModel: PriceModel
        where TProductFileModel: ProductFileModel
    {
        public BasketBaseBuilder()
        {
        }

        public BasketBaseBuilder(ISiteRules rules)
            : base(rules)
        {
        }

        public TBasketModel MapBasketModel(Basket basket)
        {
            return Mapper.Map<TBasketModel>(basket);
        }

        public Basket MapBasket(TBasketModel basketModel)
        {
            return Mapper.Map<Basket>(basketModel);
        }

        public TBasketItemModel MapBasketItemModel(BasketItem basketItem)
        {
            return Mapper.Map<TBasketItemModel>(basketItem);
        }

        public BasketItem MapBasketItem(TBasketItemModel basketItemModel)
        {
            return Mapper.Map<BasketItem>(basketItemModel);
        }
    }
}
